#include<bits/stdc++.h>
using namespace std;
int nn,mm,T,aa[100005],n[100005],a[100005],s=1;
string s[40];
int ge(int x){
    int a=1,sum=0;
    while(a!=x){
        a*=2;sum++;
    }
    return sum;
}
int work(int w){
    int p=ge(n[w]);
    int wo[n[w]];
    memset(wo,0,sizeof(wo));
    int step=0,bo=1;
    while(n[w]){
        n[w]>>=1;
    }
}
int main(){
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>nn>>mm;
    for(int i=1;i<=nn;i++)cin>>aa[i];
    int maxn=-1;
    for(int i=1;i<=mm;i++){
        cin>>n[i];
        maxn=max(maxn,n[i]);
    }
    int pp=ge(maxn);
    for(int i=pp;i>=1;i--)cin>>s[i];    
    cin>>T;
    int xa,xb,xc,xd;
    cin>>xa>>xb>>xc>>xd;
    for(int i=1;i<=100000;i++){
        if(i%4==0)a[i]=aa[i]^xa;
        else if(i%4==1)a[i]=aa[i]^xb;
        else if(i%4==2)a[i]=aa[i]^xc;
        else a[i]=aa[i]^xd;
    }
    for(int w=1;w<=mm;w++){
        work(w);
    }
    return 0;
}